home *** CD-ROM | disk | FTP | other *** search
Text File | 1998-12-03 | 10.2 KB | 299 lines | [TEXT/MPS ] |
- Instructions - The C Examples
-
- Copyright Apple Computer, Inc. © 1987-1995
- All rights reserved.
-
-
- About the Examples
-
- Eight sample C programs are included with ETO: an application,
- a tool, a desk accessory, and a program that demonstrates the
- use of performance tools:
-
- Sample - a simple MultiFinder-Aware Sample application
- TESample - a simple MultiFinder-Aware TextEdit application
- SillyBalls - a simple Color Quickdraw sample application
- (Requires Color Quickdraw)
- TubeTest - a simple Color Quickdraw & Palette Manager
- Sample application
- (Requires Color Quickdraw)
- Count - an MPW tool
- Memory - a sample desk accessory
- EditCdev - a sample Control Panel Device with a TextEdit item
- TestPerf - a performance demonstration tool
-
- The source files for each of these examples are in the
- "Examples:CExamples:" folder. A single makefile is provided
- which contains the commands necessary to build each of the
- targets.
-
-
- Building the Examples
-
- You can easily build each of the sample programs using the Directory
- and Build menus. (See "Building & Managing Programs In MPW".)
-
- Set the default directory to "CExamples:"
-
- The simplest way to do this is to select from the Directory menu
- the menu item that ends in "CExamples:". You can also set the
- default directory by using the Directory and SetDirectory commands.
-
-
- Build the program
-
- To build a sample application, type "make <sample name>".
- You may redirect the output of make to a temporary file,
- using the redirection character ">"; or, you may allow make
- to write to the current window.
-
- For example,
-
- make Count > Count.makeout
-
- Will generate the build commands for the Count sample,
- and redirect output to a file (which is created) named
- Count.makeout. You may then execute Count.makeout.
-
- Sample - A Simple MultiFinder-Aware Sample Application
-
- Sample is an example application that demonstrates how to initialize
- the commonly used toolbox managers, operate successfully under
- MultiFinder, handle desk accessories and create, grow, and zoom windows.
- The source for Sample (or TESample below) provides an excellent
- framework for basing new applications.
- The source is contained in the files Sample.c and Sample.h, resource
- descriptions are contained in the files Sample.h and Sample.r.
- The make dependency file is named Sample.make.
-
- To build Sample, simply select the lines below and press Enter.
-
- make Sample > Sample.makeout
- Sample.makeout
- delete Sample.makeout
-
- To execute Sample, select the line below and press Enter.
-
- Sample
-
-
-
- TESample - A Simple MultiFinder-Aware TextEdit Application
-
- TESample is an example application that demonstrates how to initialize
- the commonly used toolbox managers, operate successfully under
- MultiFinder, handle desk accessories and create, grow, and zoom windows.
- The fundamental TextEdit toolbox calls and TextEdit autoscroll are
- demonstrated. TESample also shows how to create and maintain scrollbar
- controls.
- The source for TESample (or Sample above) provides an excellent
- framework for basing new applications.
- The source is contained in the files TESample.c, TESampleGlue.a and
- TESample.h, resource descriptions are contained in the files
- TESample.h and TESample.r. The make dependency file is named
- TESample.make.
-
- To build TESample, simply select the lines below and press Enter.
-
- make TESample > TESample.makeout
- TESample.makeout
- delete TESample.makeout
-
- To execute TESample, select the line below and press Enter.
-
- TESample
-
-
-
- SillyBalls - A Simple Color Quickdraw Sample Application
-
- (Requires Color Quickdraw, e.g. MacII)
-
- SillyBalls is a very simple sample program that demonstrates
- how to use Color QuickDraw. It is about two pages of code, and
- does nothing more than open a color window and draw randomly
- colored ovals in the window.
- The purpose is to show how to get some initial results with Color
- QuickDraw. It is a complete program and is very short to be as
- clear as possible.
- The source is contained in the file SillyBalls.c.
-
- To build SillyBalls, simply select the lines below and press Enter.
-
- make SillyBalls > SillyBalls.makeout
- SillyBalls.makeout
- delete SillyBalls.makeout
-
- To execute SillyBalls, select the line below and press Enter.
-
- SillyBalls
-
-
-
- TubeTest - A Simple Color Quickdraw & Palette Manager Sample Application
-
- (Requires Color Quickdraw, e.g. MacII)
-
- TubeTest is a simple demonstration of how to use
- the Palette Manager in a color program. It has a special color
- palette that is associated with the main window. The colors are
- animated using the Palette Manager to give a flowing tube effect.
- The program is very simple, and the Palette Manager and drawing
- parts are put in separate subroutines to make it easier to figure
- out what is happening.
- The source is contained in the files TubeTest.c and TubeTest.r
-
- To build TubeTest, simply select the lines below and press Enter.
-
- make TubeTest > TubeTest.makeout
- TubeTest.makeout
- delete TubeTest.makeout
-
- To execute TubeTest, select the line below and press Enter.
-
- TubeTest
-
-
-
- Count - A Sample MPW Tool
-
- Count, a tool that runs in the MPW environment, counts characters and
- lines in files. A version of Count is included with MPW, and is
- documented in the MPW Command Reference. The source for Count is in
- the files Count.c, FStubs.c, and Count.r. MakeFile contains the
- commands for building Count.
-
- To build Count, simply select the lines below and press Enter.
-
- make Count > Count.makeout
- Count.makeout
- delete Count.makeout
-
- To test Count, try counting the characters in file Count.c.
-
- Count -c Count.c ∑∑ "{Worksheet}"
-
-
-
- Memory - A Sample Desk Accessory
-
-
- Memory is a sample desk accessory written in C. It displays the memory
- available in the application and system heaps, and on the boot disk.
- MakeFile contains the commands for building Memory.
-
- To build Memory, simply select the line below and press Enter.
-
- make Memory > Memory.makeout
- Memory.makeout
- delete Memory.makeout
-
- To launch the Memory DA, switch to the Finder and double-click
- on the Memory icon.
-
-
-
- EditCdev - A Sample Control Panel Device in C
-
- EditCdev demonstrates how to implement a editText item
- in a Control Panel Device. It utilizes the new undo, cut, copy,
- paste, and delete messages that are sent to cdevs in
- response to user menu selections.
-
- To build EditCdev, simply select the line below and press Enter.
-
- make EditCdev > EditCdev.makeout
- EditCdev.makeout
- delete EditCdev.makeout
-
- To execute EditCdev, after building it, simply select the Control
- Panel from the Apple menu, and open the EditCdev icon in the list
- of Control Panels.
-
-
-
- TestPerf - An example of Using Performance Tools in C
-
- TestPerf is an MPW tool that demonstrates the use of the performance
- measurement tools. MakeFile contains the commands for building TestPerf.
- Several of the latest PowerPC machines will not have ROM maps supplied.
- Do not build TestPerf on such a machine.
-
- To build TestPerf, simply select the line below and press Enter.
-
- make TestPerf > TestPerf.makeout
- TestPerf.makeout
- delete TestPerf.makeout
-
- To execute TestPerf, select and execute the following command. (This
- test will run about 15 to 60 seconds, depending upon the machine, with
- only internal computations being performed):
-
- TestPerf
-
- TestPerf's raw performance data is written to the file Perform.out.
- In this sample use of the performance measurement tools, the ROM was
- measured. So the ROM link map file needs to be combined with the program
- link map file. Because there are many different ROM maps, the build
- process for TestPerf automatically appends the appropriate ROM map
- for the current machine to the link map file. If you wish to do
- this manually (for the cases where the program will be executed on
- a machine other than the one used to build the program), you can
- use a command similar to one of these:
-
-
- # For Macintosh IIfx:
- Catenate "{MPW}ROM Maps:MacIIfxROM.map" >> TestPerf.map
-
- # For Macintosh Quadra 950:
- Catenate "{MPW}ROM Maps:MacQuadra950ROM.map" >> TestPerf.map
-
- # For Macintosh Quadra 840AV:
- Catenate "{MPW}ROM Maps:MacQuadra840AVROM.map" >> TestPerf.map
-
- And so on…
-
- PerformReport is an MPW Tool that combines the output of the performance
- tools with the link map file and produces a list of procedures, sorted by
- estimated percent of time spent in each procedure. To run PerformReport
- execute the following command:
-
- PerformReport -l TestPerf.map -m Perform.Out > Report.Out
-
- The output of PerformReport is written to the file Report.Out. To examine
- this output, execute the following command:
-
- Open Report.Out
-
-
- Writing Your Own Programs
-
- After building (and perhaps modifying) the sample programs, you will
- undoubtedly want to write a program of your own. Use the New… item in
- the File menu, to create the source files. Remember that C language
- source filenames should end in .c.
-
- Create Build Commands… - The Create Build Commands… item in the
- Build menu runs a script that creates a makefile containing the
- commands for building programs written in C, Assembly Language, Pascal,
- and/or Rez. Selecting Create Build Commands… displays a dialog box that
- allows you to enter information about your program. Type the program's
- name, select its source files by clicking the Files… button, and click
- one of the radio buttons to indicate your choice of an application, tool,
- or desk accessory.
-
- Create Build Commands… puts the makefile for your program in the file
- <program>.make. Now you can use the Build menu to build and rebuild
- your program, just as with the examples.
-
- Larger Programs - If you add source files as your program grows,
- use Create Build Commands… again to add the new source files to the build
- instructions. If you out-grow the capabilities of the simple Create
- Build Commands… script (perhaps by using tools other than Asm, C, Pascal,
- Rez, and Link in your builds) you can modify the makefile yourself.
-
- Modifying the Directory and Build Menus - The Directory and Build
- menus are both implemented using scripts written in the MPW Shell
- command language. This has the big advantage that you can modify
- or customize them to match the way you work.
-